<template>
  <view>
    <m-top
      :autoBack="true"
      :bgChangeByScroll="true"
      bgColor="#8C82FF"
      @getHeight="getGlHeight"
    >
      <view class="c333 font32 fw500">资讯中心</view>
    </m-top>

    <m-container :top="glTop">
      <view class="mgt32 pdv40">
        <view class="news flex flex-wrap">
          <view class="news-item" v-for="(item, index) in list" :key="index" @click="$u.route({
          url: '/pages-details/news/detail',
          params: {
            id: item.ti_id,
            from: 'home'
          }
        })">
            <image
              class="news-item__img flex"
              :src="getImgUrl(item.ti_icon)"
            ></image>

            <view class="news-item__desc">
              <view class="c333 font28 desc-text">{{ item.ti_title }} </view>
              <view class="c999 font24 mgt20">{{
                $timeFilter(item.ti_add_date, "YYYY/MM/DD")
              }}</view>
            </view>
          </view>
        </view>
      </view>
    </m-container>
  </view>
</template>

<script>
import GlTopMixin from "@/mixins/global-top";
import { getInfomationApi } from "@/api/modules/homepage.js";

export default {
  mixins: [GlTopMixin],
  components: {},
  data() {
    return {
      list: [],
    };
  },

  async onLoad() {
    uni.showLoading({
      title: "加载中",
    });
    try {
      const response = await getInfomationApi(53); // 重磅嘉宾
      this.list = response.data || [];
    } catch (error) {}
    uni.hideLoading();
  },
};
</script>

<style lang="scss" scoped>
.news-item {
  box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(72, 30, 193, 0.1);
  border-radius: 20rpx;
  overflow: hidden;
  margin-top: 20rpx;
  margin-right: 20rpx;
  background-color: white;
  width: calc((100% - 20rpx) / 2);
  flex-shrink: 0;

  &:nth-child(2n) {
    margin-right: 0;
  }

  &__img {
    height: 188rpx;
    width: 100%;
  }

  &__desc {
    padding: 20rpx;
  }
}
</style>
